<!doctype html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  
    
      
    

    
  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic|PT Mono:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/blog/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="公众号 微信" />








  <link rel="shortcut icon" type="image/x-icon" href="/blog/favicon.ico?v=5.1.0" />






<meta name="description" content="微信开发全过程(node)

本地进行微信公众号的开发和调试最开始是放在个人服务器上的。但是每次测试时部署麻烦，后来尝试使用natapp.cn通过内网穿透实现本地测试。
注册后，可以尝试先使用免费的。网站自带教程点击这里
由于我是mac电脑 使用natapp需要先授权chmod a+x natapp然后运行./natapp(推荐使用config.ini方式，配置好authtoken，放在同级目录">
<meta property="og:type" content="article">
<meta property="og:title" content="本地开发公众号(测试号)">
<meta property="og:url" content="https://rsl140.github.io/blog/2017/10/23/natapp/index.html">
<meta property="og:site_name" content="XiaoSi">
<meta property="og:description" content="微信开发全过程(node)

本地进行微信公众号的开发和调试最开始是放在个人服务器上的。但是每次测试时部署麻烦，后来尝试使用natapp.cn通过内网穿透实现本地测试。
注册后，可以尝试先使用免费的。网站自带教程点击这里
由于我是mac电脑 使用natapp需要先授权chmod a+x natapp然后运行./natapp(推荐使用config.ini方式，配置好authtoken，放在同级目录">
<meta property="og:image" content="https://user-images.githubusercontent.com/7655291/32205958-4ff84272-bdc0-11e7-97d9-fcb2c23dccba.jpg">
<meta property="og:updated_time" content="2017-10-31T03:21:57.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="本地开发公众号(测试号)">
<meta name="twitter:description" content="微信开发全过程(node)

本地进行微信公众号的开发和调试最开始是放在个人服务器上的。但是每次测试时部署麻烦，后来尝试使用natapp.cn通过内网穿透实现本地测试。
注册后，可以尝试先使用免费的。网站自带教程点击这里
由于我是mac电脑 使用natapp需要先授权chmod a+x natapp然后运行./natapp(推荐使用config.ini方式，配置好authtoken，放在同级目录">
<meta name="twitter:image" content="https://user-images.githubusercontent.com/7655291/32205958-4ff84272-bdc0-11e7-97d9-fcb2c23dccba.jpg">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/blog/',
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://rsl140.github.io/blog/2017/10/23/natapp/"/>





  <title> 本地开发公众号(测试号) | XiaoSi </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  














  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">XiaoSi</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/blog/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/blog/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="https://rsl140.github.io/blog/blog/2017/10/23/natapp/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Summer">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/uploads/1.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="XiaoSi">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                本地开发公众号(测试号)
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-10-23T11:48:08+08:00">
                2017-10-23
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/wechat/" itemprop="url" rel="index">
                    <span itemprop="name">wechat</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/blog/2017/10/23/natapp/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count disqus-comment-count" data-disqus-identifier="2017/10/23/natapp/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv"><i class="fa fa-file-o">阅读次数</i>
            <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>次
            </span>
          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <blockquote>
<p>微信开发全过程(node)</p>
</blockquote>
<h1 id="本地进行微信公众号的开发和调试"><a href="#本地进行微信公众号的开发和调试" class="headerlink" title="本地进行微信公众号的开发和调试"></a>本地进行微信公众号的开发和调试</h1><p>最开始是放在个人服务器上的。但是每次测试时部署麻烦，后来尝试使用<a href="https://natapp.cn" target="_blank" rel="external">natapp.cn</a>通过内网穿透实现本地测试。</p>
<p>注册后，可以尝试先使用免费的。<a href="https://natapp.cn/article/natapp_newbie" target="_blank" rel="external">网站自带教程点击这里</a></p>
<p>由于我是mac电脑 使用natapp需要先授权<code>chmod a+x natapp</code>然后运行<code>./natapp</code>(推荐使用<code>config.ini</code>方式，配置好<code>authtoken</code>，放在同级目录下即可)</p>
<p>链接时遇到一直链接不上服务器的问题，仔细看了下教程，应该是DNS问题，修改本地DNS为阿里云公共DNS：<code>223.5.5.5</code> <code>223.6.6.6</code>后，成功链接。</p>
<h1 id="账号链接-测试号"><a href="#账号链接-测试号" class="headerlink" title="账号链接(测试号)"></a>账号链接(测试号)</h1><h2 id="微信接口配置信息"><a href="#微信接口配置信息" class="headerlink" title="微信接口配置信息"></a>微信接口配置信息</h2><p>URL：填写服务器地址(需有appid信息相符才能验证成功)<br>Token：任意填写(后面的配置需与填写的一致)</p>
<h2 id="创建项目"><a href="#创建项目" class="headerlink" title="创建项目"></a>创建项目</h2><p>开发语言：node.js<br>开发框架：express，express教程参考<a href="http://expressjs.com/" target="_blank" rel="external">官网</a><br>插件：<a href="https://github.com/node-webot/wechat" target="_blank" rel="external">wechat</a>、<a href="https://github.com/node-webot/wechat-api" target="_blank" rel="external">wechat-api</a></p>
<h2 id="建立接口链接"><a href="#建立接口链接" class="headerlink" title="建立接口链接"></a>建立接口链接</h2><h3 id="创建路由"><a href="#创建路由" class="headerlink" title="创建路由"></a>创建路由</h3><a id="more"></a>
<p>由于是在express基础上编程，首先在routes文件夹下添加wechat.js路由文件<br><figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> express = <span class="built_in">require</span>(<span class="string">'express'</span>);</div><div class="line"><span class="keyword">var</span> router = express.Router();</div><div class="line"><span class="keyword">var</span> wechat = <span class="built_in">require</span>(<span class="string">'wechat'</span>);<span class="comment">//&lt;---引入wechat插件</span></div><div class="line"></div><div class="line"><span class="keyword">var</span> config = &#123;</div><div class="line">  <span class="attr">token</span> : <span class="string">'you token'</span>,</div><div class="line">  <span class="attr">appid</span> : <span class="string">'you appid'</span>,</div><div class="line">  <span class="attr">appsecret</span> :<span class="string">'you appsecret'</span>,</div><div class="line">  <span class="attr">encodingAESKey</span> : <span class="string">''</span></div><div class="line">&#125;;</div><div class="line"></div><div class="line">router.use(express.query());</div><div class="line"></div><div class="line">router.use(<span class="string">'/'</span>, wechat(config, <span class="function"><span class="keyword">function</span>(<span class="params">req, res, next</span>) </span>&#123;</div><div class="line">    <span class="built_in">console</span>.log(req.weixin);</div><div class="line">    <span class="keyword">var</span> message = req.weixin;</div><div class="line">    <span class="comment">//文本</span></div><div class="line">    <span class="keyword">if</span> (message.Content === <span class="string">'1'</span>) &#123;</div><div class="line"></div><div class="line">        res.reply(<span class="string">'hehe'</span>);</div><div class="line">    &#125;</div><div class="line"></div><div class="line">&#125;));</div><div class="line"></div><div class="line"><span class="built_in">module</span>.exports = router;</div></pre></td></tr></table></figure></p>
<h3 id="app-js修改"><a href="#app-js修改" class="headerlink" title="app.js修改"></a>app.js修改</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> express = <span class="built_in">require</span>(<span class="string">'express'</span>);</div><div class="line"><span class="keyword">var</span> path = <span class="built_in">require</span>(<span class="string">'path'</span>);</div><div class="line"><span class="keyword">var</span> favicon = <span class="built_in">require</span>(<span class="string">'serve-favicon'</span>);</div><div class="line"><span class="keyword">var</span> logger = <span class="built_in">require</span>(<span class="string">'morgan'</span>);</div><div class="line"><span class="keyword">var</span> cookieParser = <span class="built_in">require</span>(<span class="string">'cookie-parser'</span>);</div><div class="line"><span class="keyword">var</span> bodyParser = <span class="built_in">require</span>(<span class="string">'body-parser'</span>);</div><div class="line"></div><div class="line"><span class="keyword">var</span> index = <span class="built_in">require</span>(<span class="string">'./routes/index'</span>);</div><div class="line"><span class="keyword">var</span> users = <span class="built_in">require</span>(<span class="string">'./routes/users'</span>);</div><div class="line"><span class="keyword">var</span> wechat = <span class="built_in">require</span>(<span class="string">'./routes/wechat'</span>);<span class="comment">// &lt;-- 增加wechat地址</span></div><div class="line"></div><div class="line"><span class="keyword">var</span> app = express();</div><div class="line"></div><div class="line"><span class="comment">// view engine setup</span></div><div class="line">app.set(<span class="string">'views'</span>, path.join(__dirname, <span class="string">'views'</span>));</div><div class="line">app.set(<span class="string">'view engine'</span>, <span class="string">'ejs'</span>);</div><div class="line"></div><div class="line"><span class="comment">// uncomment after placing your favicon in /public</span></div><div class="line"><span class="comment">// app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));</span></div><div class="line">app.use(logger(<span class="string">'dev'</span>));</div><div class="line">app.use(bodyParser.json());</div><div class="line">app.use(bodyParser.urlencoded(&#123; <span class="attr">extended</span>: <span class="literal">false</span> &#125;));</div><div class="line">app.use(cookieParser());</div><div class="line">app.use(express.static(path.join(__dirname, <span class="string">'public'</span>)));</div><div class="line"></div><div class="line">app.use(<span class="string">'/'</span>, index);</div><div class="line">app.use(<span class="string">'/users'</span>, users);</div><div class="line"><span class="comment">// 调用微信接口</span></div><div class="line">app.use(<span class="string">'/wechat'</span>, wechat);<span class="comment">// &lt;-- 调用微信接口</span></div><div class="line"></div><div class="line"><span class="comment">// catch 404 and forward to error handler</span></div><div class="line">app.use(<span class="function"><span class="keyword">function</span>(<span class="params">req, res, next</span>) </span>&#123;</div><div class="line">  <span class="keyword">var</span> err = <span class="keyword">new</span> <span class="built_in">Error</span>(<span class="string">'Not Found'</span>);</div><div class="line">  err.status = <span class="number">404</span>;</div><div class="line">  next(err);</div><div class="line">&#125;);</div><div class="line"></div><div class="line"><span class="comment">// error handler</span></div><div class="line">app.use(<span class="function"><span class="keyword">function</span>(<span class="params">err, req, res, next</span>) </span>&#123;</div><div class="line">  <span class="comment">// set locals, only providing error in development</span></div><div class="line">  res.locals.message = err.message;</div><div class="line">  res.locals.error = req.app.get(<span class="string">'env'</span>) === <span class="string">'development'</span> ? err : &#123;&#125;;</div><div class="line"></div><div class="line">  <span class="comment">// render the error page</span></div><div class="line">  res.status(err.status || <span class="number">500</span>);</div><div class="line">  res.render(<span class="string">'error'</span>);</div><div class="line">&#125;);</div><div class="line"></div><div class="line"><span class="built_in">module</span>.exports = app;</div></pre></td></tr></table></figure>
<p>改造完成后运行程序，建立连接。配置完成。</p>
<h1 id="菜单创建-wechar-api使用"><a href="#菜单创建-wechar-api使用" class="headerlink" title="菜单创建(wechar-api使用)"></a>菜单创建(wechar-api使用)</h1><h2 id="根目录下创建config-json文件"><a href="#根目录下创建config-json文件" class="headerlink" title="根目录下创建config.json文件"></a>根目录下创建config.json文件</h2><p>存储基本数据<span style="color: red;">（注：注释内容务必删除，json不支持注释功能）</span><br><figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div></pre></td><td class="code"><pre><div class="line">&#123;</div><div class="line">    "token":"youtoken",</div><div class="line">    "appID": "youappID",</div><div class="line">    "appSecret": "youappSecret",</div><div class="line">    "encodingAESKey": "",</div><div class="line">      "menu": &#123;// 菜单内容，微信详细数据参考管方文档 </div><div class="line">        "button": [</div><div class="line">            &#123;</div><div class="line">                "type": "click",</div><div class="line">                "name": "1",</div><div class="line">                "key": "V1001_TODAY_MUSIC"</div><div class="line">            &#125;,</div><div class="line">            &#123;</div><div class="line">              "name":"2",</div><div class="line">              "sub_button": [</div><div class="line">                  &#123;</div><div class="line">                    "type": "click",</div><div class="line">                    "name": "2.1",</div><div class="line">                    "key": "V1001_TODAY_SHARE"</div><div class="line">                  &#125;,</div><div class="line">                  &#123;</div><div class="line">                    "type": "click",</div><div class="line">                    "name": "2.2",</div><div class="line">                    "key": "V1001_STU_SHARE"</div><div class="line">                  &#125;</div><div class="line">              ]</div><div class="line">            &#125;,</div><div class="line">            &#123;</div><div class="line">                "type": "click",</div><div class="line">                "name": "3",</div><div class="line">                "key": "V1001_MY_STUDAY"</div><div class="line">            &#125;</div><div class="line">        ]</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<h2 id="改造wechat-js"><a href="#改造wechat-js" class="headerlink" title="改造wechat.js"></a>改造wechat.js</h2><figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> express = <span class="built_in">require</span>(<span class="string">'express'</span>);  </div><div class="line"><span class="keyword">var</span> router = express.Router();</div><div class="line"><span class="comment">// 引入微信插件</span></div><div class="line"><span class="keyword">var</span> wechat = <span class="built_in">require</span>(<span class="string">'wechat'</span>);</div><div class="line"><span class="keyword">var</span> WechatAPI = <span class="built_in">require</span>(<span class="string">'wechat-api'</span>);<span class="comment">//&lt;--调用wechat-api</span></div><div class="line"><span class="comment">// 引入config</span></div><div class="line"><span class="keyword">var</span> configApi = <span class="built_in">require</span>(<span class="string">'../config.json'</span>);<span class="comment">//&lt;--调用config</span></div><div class="line">  </div><div class="line"><span class="keyword">var</span> config = configApi;</div><div class="line">  </div><div class="line">router.use(express.query());</div><div class="line"><span class="comment">// use wechat-api</span></div><div class="line"><span class="keyword">var</span> api = <span class="keyword">new</span> WechatAPI(config.appID, config.appSecret);<span class="comment">//&lt;--创建api实例</span></div><div class="line"></div><div class="line"><span class="keyword">var</span> menu = configApi.menu;<span class="comment">//&lt;--提取config中的菜单内容</span></div><div class="line">  </div><div class="line">router.use(<span class="string">'/'</span>, wechat(config, <span class="function"><span class="keyword">function</span>(<span class="params">req, res, next</span>) </span>&#123;  </div><div class="line">  <span class="built_in">console</span>.log(req.weixin);  </div><div class="line">  <span class="keyword">var</span> message = req.weixin;  </div><div class="line">  <span class="comment">//文本  </span></div><div class="line">  <span class="keyword">if</span> (message.Content === <span class="string">'1'</span>) &#123;  </div><div class="line"></div><div class="line">      res.reply(<span class="string">'hehe'</span>);  </div><div class="line">  &#125;</div><div class="line">  <span class="comment">// 第一次关注发送欢迎信息</span></div><div class="line">  <span class="keyword">if</span>(message.MsgType === <span class="string">'event'</span> &amp;&amp; message.Event === <span class="string">'subscribe'</span>) &#123;</div><div class="line"></div><div class="line">    res.reply(<span class="string">'Hello world'</span>);</div><div class="line">  &#125;</div><div class="line">&#125;));</div><div class="line"><span class="comment">// 创建微信菜单</span></div><div class="line">api.createMenu(menu, <span class="function"><span class="keyword">function</span>(<span class="params">err, result</span>)</span>&#123;</div><div class="line">     <span class="built_in">console</span>.log(result);</div><div class="line">     <span class="built_in">console</span>.log(err);</div><div class="line">    &#125;);</div><div class="line"><span class="built_in">module</span>.exports = router;</div></pre></td></tr></table></figure>
<h2 id="项目目录"><a href="#项目目录" class="headerlink" title="项目目录"></a>项目目录</h2><p><img src="https://user-images.githubusercontent.com/7655291/32205958-4ff84272-bdc0-11e7-97d9-fcb2c23dccba.jpg" alt="项目目录"></p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/blog/tags/微信开发/" rel="tag"># 微信开发</a>
          
        </div>
      

      
        
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/blog/2017/09/06/ECM6初探/" rel="next" title="ECM6初探">
                <i class="fa fa-chevron-left"></i> ECM6初探
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/blog/2017/10/31/vue/" rel="prev" title="Vue2.0">
                Vue2.0 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div id="disqus_thread">
        <noscript>
          Please enable JavaScript to view the
          <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a>
        </noscript>
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/blog/uploads/1.jpg"
               alt="Summer" />
          <p class="site-author-name" itemprop="name">Summer</p>
           
              <p class="site-description motion-element" itemprop="description">小思</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/blog/archives/">
                <span class="site-state-item-count">27</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/blog/categories/index.html">
                <span class="site-state-item-count">8</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/blog/tags/index.html">
                <span class="site-state-item-count">17</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="http://github.com/rsl140" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://segmentfault.com/u/xiaosi_58ec6bdf9eaab" target="_blank" title="Segmentfault">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  Segmentfault
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#本地进行微信公众号的开发和调试"><span class="nav-number">1.</span> <span class="nav-text">本地进行微信公众号的开发和调试</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#账号链接-测试号"><span class="nav-number">2.</span> <span class="nav-text">账号链接(测试号)</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#微信接口配置信息"><span class="nav-number">2.1.</span> <span class="nav-text">微信接口配置信息</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#创建项目"><span class="nav-number">2.2.</span> <span class="nav-text">创建项目</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#建立接口链接"><span class="nav-number">2.3.</span> <span class="nav-text">建立接口链接</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#创建路由"><span class="nav-number">2.3.1.</span> <span class="nav-text">创建路由</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#app-js修改"><span class="nav-number">2.3.2.</span> <span class="nav-text">app.js修改</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#菜单创建-wechar-api使用"><span class="nav-number">3.</span> <span class="nav-text">菜单创建(wechar-api使用)</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#根目录下创建config-json文件"><span class="nav-number">3.1.</span> <span class="nav-text">根目录下创建config.json文件</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#改造wechat-js"><span class="nav-number">3.2.</span> <span class="nav-text">改造wechat.js</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#项目目录"><span class="nav-number">3.3.</span> <span class="nav-text">项目目录</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Summer</span>
</div>

        
<div class="busuanzi-count">
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user">本站访客数</i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      人次
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye">本站总访问量</i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      次
    </span>
  
</div>


        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  



  
  <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>

  
  <script type="text/javascript" src="/blog/lib/canvas-nest/canvas-nest.min.js"></script>


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.0"></script>



  
  

  
  <script type="text/javascript" src="/blog/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/blog/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.0"></script>



  



  

    <script type="text/javascript">
      var disqus_shortname = 'xiaosi';
      var disqus_identifier = '2017/10/23/natapp/';

      var disqus_title = "本地开发公众号(测试号)";


      function run_disqus_script(disqus_script) {
        var dsq = document.createElement('script');
        dsq.type = 'text/javascript';
        dsq.async = true;
        dsq.src = '//' + disqus_shortname + '.disqus.com/' + disqus_script;
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
      }

      run_disqus_script('count.js');

      
        var disqus_config = function () {
            this.page.url = disqus_url;
            this.page.identifier = disqus_identifier;
            this.page.title = disqus_title;
        };
        run_disqus_script('embed.js');
      

    </script>
  













  





  

  

  

  

</body>
</html>
